 /*********************************************************************************
 *     Copyright:  (C) 2022 Nikel
 *                 All rights reserved.
 *
 *    Filename:  bc28.h
 *    Description:  This file is for bc28 module to communication
 *
 *    Version:  1.0.0
 *    Author:  zhouyanlin <www.zhouyanlin1222@qq.com>
 *    ChangeLog:  1, Release initial version on "06/05/22 08:52:15"
 *
 ********************************************************************************/

#ifndef INC_BC28_H_
#define INC_BC28_H_

#include "at_cmd.h"


/*
 * Description:
 * 				NB-IoT Module reset function
 *
 * Input Value: void
 *
 * Return Value:
 * 				 0: NB-IoT Module reset OK
 * 				-1: NB-IoT Module reset fail
 *
 */
extern int nb_iot_reset(void);


/*
 * Description:
 * 				Nb-iot initializes the module function
 * 				Pass a frequency band that needs to be set, and send AT to test whether the module works normally
 * 				Then restart the module, set the module to this frequency band,
 * 				and finally check whether the card reading is successful
 *
 *
 * Input Value:
 * 				@ frequency_band_at：the working frequency band
 *
 * Return Value:
 * 				 0: NB-IoT Module initial OK
 * 				-1: Error in passed parameter
 *				-2:The module is abnormal
 *				-3:Failed to restart the module
 *				-5:Failure to set frequency band
 *				-7:Failed to read the SIM card
 *
 */
extern int nb_iot_module_init(char *frequency_band_at);


/*
 * Description:
 * 				Nb-iot Module connects to cloud platform function
 * 				Pass in the AT instructions that input the IP and port of the connection cloud platform,
 * 				and connect the corresponding cloud platform,
 * 				And initiate the cloud platform registration instruction,
 * 				and finally return the registration result
 *
 * Input Value:
 * 				 @frequency_band_at:Cloud platform IP+Port AT instruction string
 *
 * Return Value:
 * 				 0: NB-IoT Module connect OK
 * 				-1: Error in passed parameter
 *				-2: Failed to send the register cloud platform command
 *				-3: Failed to register the cloud platform.
 *
 */
extern int nb_iot_connect(char *paltform_at);


/*
 * Description:
 * 				Nb-iot module obtains the signal strength
 *
 * Input Value: void
 *
 * Return Value:
 * 				 >=0: NB-IoT Module signal strength
 * 				 -1:  fail
 *
 */
extern int nb_iot_get_sign(void);


/*
 * Description:
 * 				Nb-iot Module sends light intensity function
 * 				Pass in an integer light intensity and send it to the connected cloud platform
 *
 * Input Value:
 * 				 @Lux: Integer light intensity
 *
 * Return Value:
 * 				 0: send success
 * 				-1: send fail
 *
 */
extern int nb_iot_send_lux(int Lux);


/*
 * Description:
 * 				Nb-iot Module sends soil humidity function
 * 				Pass in an integer of soil moisture and send it to the connected cloud platform
 *
 * Input Value:
 * 				  @humidity: Integral soil humidity
 *
 * Return Value:
 * 				 0: send success
 * 				-1: send fail
 *
 */
extern int nb_iot_send_soil_humidity(int humidity);


/*
 * Description:
 * 				Nb-iot The module sends the air temperature and humidity function
 * 				Pass in the number of tokens and temperature and humidity values
 * 				that need to be sent and send them to the connected cloud platform
 *
 * Input Value:
 * 				  @temperature：Floating point temperature value
 * 				  @humidity：Floating point humidity value
 *
 * Return Value:
 * 				 0: send success
 * 				-1: send temperature fail
 * 				-2: send humidity fail
 *
 */
extern int nb_iot_send_TH(float temperature, float humidity);


/*
 * Description:
 * 				Nb-iot Module sends signal strength function
 *
 * Input Value:
 * 				  @ sign: Integer signal strength
 *
 * Return Value:
 * 				 0: send success
 * 				-1: send fail
 *
 */
extern int nb_iot_send_sign(int sign);


/*
 * Description:
 * 				Receive and parse the instructions sent from the cloud platform,
 * 				operate the relay and control the LED lights on or off according to the instructions
 *
 * Input Value:
 * 				  @ cmd: A command string from cloud platform
 *
 * Return Value:
 * 				 0: success
 * 				-1: fail
 *
 */
extern int parse_recv_cmd(char * cmd);


#endif /* INC_BC28_H_ */
